﻿using System.Collections.Concurrent;
using System.Linq;
using Synapse.Framework.Pipe.BusinessObjects;
using Synapse.Framework.Pipe.Filters;

namespace Synapse.Framework.Pipe.PipeLines
{
    public class PipeLine : IPipeLine
    {
        private readonly BlockingCollection<IFilter> filters = new BlockingCollection<IFilter>();

        public void Add(IFilter filter)
        {
            filters.Add(filter);
        }

        public void Execute(IBusinessObject input)
        {
            filters.Aggregate(input, (current, filter) => current.Accept(filter));
        }
    }
}
